from datetime import datetime
import re
import time

from business.Admin.TrainingBank import TrainingBank
import unittest
from business.login import Login
from pom.base import BaseDriver
from ddt import data, ddt, unpack
from selenium import webdriver
from business.Admin.ComBank import ComBank

@ddt
class TestComBank(unittest.TestCase, BaseDriver):

    def setUp(self):
        self.driver = webdriver.Chrome()
        BaseDriver(self.driver).get_url()
        self.l = Login(self.driver)
        self.combank = ComBank(self.driver)
        self.trb = TrainingBank(self.driver)
        # self.l.account_login("jiayingjie@forensix.cn", "Jyj1234!")
        self.l.account_login("admin@forensix.cn", "123456")
        self.combank.jump_competation_bank()
        time.sleep(1)

    def tearDown(self) -> None:
        time.sleep(10)
        BaseDriver(self.driver).quit_webdriver()

    # @unittest.skip
    def test_create_combank(self):
        title = datetime.now().strftime("%Y%m%d-%H%M%S")
        self.trb.create_bank(1, title=title, desc="简介简介简介简介", image=2, otherdesc="其他说明其他说明")
        time.sleep(0.5)
        self.assertEqual(self.trb.bank_list_data(1, 2), title)

# 创建题目
    def test_add_question(self):
        self.combank.click_title(1)
        self.combank.add_question("select_type", [1, 2])


if __name__ == '__main__':
    unittest.main()